﻿using CPPEI.Coolzon.Common;
using CPPEI.Coolzon.Service.Contract;
using Sunboxsoft.ChanceData.ServiceProxy.MainServiceRef;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI.Coolzon.UI.Views.EventProxies
{
    public abstract class BaseResponseHandler<T> : IResponseHandler
    {
        public BaseResponseHandler()
        {
        }

        public void OnHandle(RemoteEventProxy remoteEventProxy, Response response)
        {
            if (response.Data != null)
            {
                T responseData = (T)SerializeUtility.DeserializeFromBinary(response.Data);
                OnHandle(remoteEventProxy, response, responseData);
            }
            else
            {
                Logger.WarningToTag(Library.LogTag, "接受到指令Data为空,Scenario:{0},Command:{1}", response.Header.Scenario, response.Header.Command);
            }
        }

        protected abstract void OnHandle(RemoteEventProxy remoteEventProxy, Response response, T responseData);
    }
}
